package com.sinbader.xiaole.admin.controller;

import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
import com.sinbader.xiaole.common.entity.BuyOrderInfoDetail;
import com.sinbader.xiaole.common.model.params.BuyOrderInfoDetailParam;
import com.sinbader.xiaole.common.service.BuyOrderInfoDetailService;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.kernel.model.response.ResponseData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;


/**
 * 采购订单明细信息表控制器
 *
 */
@Api("采购订单明细信息表")
@Controller
@RequestMapping("/buyOrderInfoDetail")
public class BuyOrderInfoDetailController extends BaseController {

    private String PREFIX = "/buyOrderInfoDetail";

    @Autowired
    private BuyOrderInfoDetailService buyOrderInfoDetailService;

    /**
     * 跳转到主页面
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "/buyOrderInfoDetail.html";
    }

    /**
     * 跳转到主页面
     */
    @RequestMapping("/orderDetailIndex")
    public String orderDetailIndex() {
        return PREFIX + "/buyOrderInfoDetail.html";
    }

    /**
     * 新增页面
     */
    @RequestMapping("/add")
    public String add() {
        return PREFIX + "/buyOrderInfoDetail_add.html";
    }

    /**
     * 编辑页面
     */
    @RequestMapping("/edit")
    public String edit() {
        return PREFIX + "/buyOrderInfoDetail_edit.html";
    }

    @ApiOperation(value = "新增")
    @PostMapping("/addItem")
    @ResponseBody
    public ResponseData addItem(BuyOrderInfoDetailParam buyOrderInfoDetailParam) {
        this.buyOrderInfoDetailService.add(buyOrderInfoDetailParam);
        return ResponseData.success();
    }

    @ApiOperation(value = "编辑")
    @PostMapping("/editItem")
    @ResponseBody
    public ResponseData editItem(BuyOrderInfoDetailParam buyOrderInfoDetailParam) {
        this.buyOrderInfoDetailService.update(buyOrderInfoDetailParam);
        return ResponseData.success();
    }

    @ApiOperation(value = "删除")
    @PostMapping("/delete")
    @ResponseBody
    public ResponseData delete(BuyOrderInfoDetailParam buyOrderInfoDetailParam) {
        this.buyOrderInfoDetailService.delete(buyOrderInfoDetailParam);
        return ResponseData.success();
    }

    @ApiOperation(value = "查看详情")
    @PostMapping("/detail")
    @ResponseBody
    public ResponseData detail(BuyOrderInfoDetailParam buyOrderInfoDetailParam) {
        BuyOrderInfoDetail detail = this.buyOrderInfoDetailService.getById(buyOrderInfoDetailParam.getId());
        return ResponseData.success(detail);
    }

    @ApiOperation(value = "查询列表")
    @GetMapping("/list")
    @ResponseBody
    public LayuiPageInfo list(BuyOrderInfoDetailParam buyOrderInfoDetailParam) {
        return this.buyOrderInfoDetailService.findPageBySpec(buyOrderInfoDetailParam);
    }

}
